<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增农场管理')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-WxFarm-add">
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">绑定用户
                ：</label>
            <div class="col-sm-10">
                <select name="farmUid" id="farmUid" class="form-control" type="text"></select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">农场名称
                ：</label>
            <div class="col-sm-10">
                <input name="farmName" id="farmName" class="form-control" required
                       type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">状态：</label>
            <div class="col-sm-10">
                <div class="radio-box" th:each="dict : ${@dict.getType('farm_state')}">
                    <input type="radio" th:id="${'farmState_' + dict.dictCode}" name="farmState"
                           th:value="${dict.dictValue}"
                           th:checked="${dict.default}">
                    <label th:for="${'farmState_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">农场规模：</label>
            <div class="col-sm-10">
                <div class="radio-box" th:each="dict : ${@dict.getType('farm_scale')}">
                    <input type="radio" th:id="${'farmScale_' + dict.dictCode}" name="farmScale"
                           th:value="${dict.dictValue}"
                           th:checked="${dict.default}">
                    <label th:for="${'farmScale_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">地址标签
                ：</label>
            <div class="col-sm-10">
                <input name="farmHostLable" id="farmHostLable" class="form-control" required
                       type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">详细地址
                ：</label>
            <div class="col-sm-10">
                <input name="farmHost" id="farmHost" class="form-control" required
                       type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">经纬度
                ：</label>
            <div class="col-sm-10">
                <input name="lanlat" id="lanlat" class="form-control" required
                       type="text">
                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 经纬度拾取器：<a target="_blank" href="https://lbs.qq.com/getPoint/">点击跳转</a></span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">联系人
                ：</label>
            <div class="col-sm-10">
                <input name="farmWorkName" id="farmWorkName" class="form-control"  required
                       type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">联系电话
                ：</label>
            <div class="col-sm-10">
                <input name="farmWorkPhone" id="farmWorkPhone" class="form-control" required
                       type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script type="text/javascript">
    var prefix = ctx + "wechat/WxFarm"


    $("#form-WxFarm-add").validate({
        focusCleanup: true
    });


    $.operate.ajaxGet(ctx + "/wechat/user/listAjax", function (result) {
        if(result.data.length==0){
            $.modal.alertError("暂无用户")
        }
        var html = "";
        for (var i = 0; i < result.data.length; i++) {
            html += "<option value='" + result.data[i].userId + "'>" + result.data[i].userName + "</option>";
        }
        $("#farmUid").append(html);
    })

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-WxFarm-add').serialize());
        }
    }
</script>
</body>
</html>
